// https : // iai.sh.cn/problem/33
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    a[i + 1] += a[i];
    ans += abs(a[i]);
  }
  cout << ans << endl;
  return 0;
}